﻿using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using OpenAdmin.Core.DbContextLocators;

namespace OpenAdmin.Core.Models;

/// <summary>
/// 角色权限表
/// </summary>
[Table("SysRolePermission")]
public class SysRolePermission : EntityRelation<ApplicationDbContextLocator>, IEntityTypeConfigure<SysRolePermission, ApplicationDbContextLocator>
{
    /// <summary>
    /// 角色id
    /// </summary>
    public int RoleId { get; set; }
    /// <summary>
    /// 权限id
    /// </summary>
    public int PermissionId { get; set; }

    public void Configure(EntityTypeBuilder<SysRolePermission> entityBuilder)
    {
        entityBuilder.HasKey(t => new { t.RoleId, t.PermissionId });
    }
}
